package com.tuan.uaa.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tuan.common.utils.BusinessExceptionUtils;
import com.tuan.uaaapi.domain.SysUser;
import com.tuan.uaa.mapper.SysUserMapper;
import com.tuan.uaa.service.SysUserService;
import com.tuan.uaaapi.domain.req.LoginReq;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;

import java.util.List;

/**
 * @author duanr
 * @description 针对表【sys_user(用户信息表)】的数据库操作Service实现
 * @createDate 2025-04-16 14:19:14
 */
@Service
public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser>
    implements SysUserService {

  @Override
  public String login(LoginReq loginReq) {
    LambdaQueryWrapper<SysUser> queryWrapper = new LambdaQueryWrapper<>();
    queryWrapper.eq(SysUser::getUserName, loginReq.getUserName());
    List<SysUser> list = this.list(queryWrapper);
    if (ObjectUtils.isEmpty(list)){
      throw  BusinessExceptionUtils.businessException("用户不存在!");
    }
    return "12345678";
  }
}
